#!/usr/bin/env python
import itk
import sys
import os
import imageTools.ITKUtils.io as io
import imageTools.ITKUtils.ifilter as ifilter
import pylab as pb
import numpy as np

def stat(mask, fname):
    mask = io.readImage(mask)
    mask_array = itk.PyBuffer.IF3.GetArrayFromImage(mask)
    img = io.readImage(fname)
    img_array = itk.PyBuffer.IF3.GetArrayFromImage(img)
    array = img_array*mask_array
    index = np.where(array>0 )
    array_1 = array[index]
    pb.hist(array_1, 200)
    pb.show()

def main():
    print sys.argv[1]
    print sys.argv[2]
    
    stat(sys.argv[1], sys.argv[2])
     

if __name__ == '__main__':
    main()

